package com.ll19.enumTest;

public class Student {
	private Grade grade;

	public void assignGrade(Grade grade) {
		this.grade = grade;
	}

	public Grade getGrade() {
		return grade;
	}

	public static void main(String[] args) {
		Student std = new Student();
		std.assignGrade(Grade.B);
		System.out.println(std.getGrade());

		// 枚举的 比较
		// 枚举对象进行比较时，比较的是在枚举中的顺序，不是简单的字符串比较。
		System.out.println(Grade.F.compareTo(Grade.A));

		// 遍历枚举
		for (Grade g : Grade.values()) {
			System.out.println("Allowed value: '" + g + "'");
		}

		// switch判断
		switch (std.getGrade()) {
		case A:
			System.out.println("excelled with a grade of A");
			break;
		case B: // fall through to C
		case C:
			System.out.println("passed with a grade of "
					+ std.getGrade().toString());
			break;
		case D: // fall through to F
		case F:
			System.out.println("failed with a grade of "
					+ std.getGrade().toString());
			break;
		case INCOMPLETE:
			System.out.println("did not complete the class.");
			break;
		}

	}
}
